import {myFetch} from '@/assets/js/utils'
const env = process.env.NODE_ENV

export default{
	// -------订单列表and订单详情页--------
	async getOrderNum(){
		const data = await myFetch({
			name: 'shopping.sys.order.num'
		})
		return data
	},
	async getOrderList({type, page}){
		const data = await myFetch({
			name: 'shopping.sys.order.info',
			type,
			page
		})
		return data
	},
	async getOrderDetail(orderId){
		const data = await myFetch({
			name: 'shopping.sys.order.detail',
			user_id: 0,
			order_id: orderId
		})
		return data
	},
	async cancleOrder(orderId){
		const data = await myFetch({
			name: 'shopping.sys.cancel.order',
			user_id: 0,
			order_id: orderId
		})
		return data
	},
	async confirmOrder(orderId){
		const data = await myFetch({
			name: 'shopping.sys.confirm.order',
			user_id: 0,
			order_id: orderId
		})
		return data
	},
	async writeComment({orderId, goodsId, content}){
		const data = await myFetch({
			name: 'shopping.sys.comment.order',
			user_id: 0,
			order_id: orderId,
			goods_id: goodsId,
			content,
			comment_picture: '',
			star_num: 5
		})
		return data
	},
	async refund({orderId, goodsId, type, reason, num}){
		const data = await myFetch({
			name: 'shopping.sys.return.goods',
			order_id: orderId,
			goods_id: goodsId,
			type,
			reason,
			num
		})
		return data
	},
	// 获取订单号
	async getOrderNo(orderFormLogId){
		const data = await myFetch({
			name: 'shopping.sys.get.order.id',
			order_form_log_id: orderFormLogId,
			user_id: 0
		})
		return data
	},
}